home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Icon / c / GetBgCol < prev    next >
Text File  |  1994-03-06  |  2KB  |  49 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Icon.GetBgCol.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.00 (05 Mar 1994)
  14.     Purpose: Retrieve the background colour of an icon.
  15. */
  16.  
  17. #include "DeskLib:Wimp.h"
  18. #include "DeskLib:WimpSWIs.h"
  19. #include "DeskLib:Icon.h"
  20. #include "DeskLib:Validation.h"
  21. #include "DeskLib:Str.h"
  22.  
  23. int Icon_GetBgCol(icon_block *icon)
  24. {
  25.   int colour;
  26.  
  27.   /* Straightforward case first...*/
  28.   if (!icon->flags.data.font)
  29.     return icon->flags.data.background;
  30.   
  31.   /* Icon is anti-aliased - read font validation string colours */
  32.   colour = Validation_ScanString(icon->data.indirecttext.validstring, 
  33.                                  iconvalid_FONTCOLOURS);
  34.  
  35.   /* No colours specified - use default */
  36.   if (colour == 0)
  37.     return colour_WHITE;
  38.   
  39.   /* Decode first colour digit */
  40.   colour = Str_DecodeHex(icon->data.indirecttext.validstring[colour]);
  41.  
  42.   /* Limit to legal value */
  43.   if (colour == -1)
  44.     colour = colour_WHITE;
  45.  
  46.   return colour;
  47. }
  48.  
  49.